tree grammar TreeWalker; 

options { 
  tokenVocab=Simplest; 
  ASTLabelType=CommonTree; 
} 


@header {package hero.antlr2;} 


prog:   stat+ ;
stat:   atom2=atom NEWLINE { System.out.println("atom2 value is " + $atom2.value); } ;
/*
  returns [int value] :   
*/
atom  returns [int value]
  @init {
    System.out.println("init");
  }
  @after {
    System.out.println("after");
  }
  :
    INT {$value = Integer.parseInt($INT.text);}
    |   ID { System.out.println($ID.text); $value = 10; }
    ;

